public class Solution {
    public int removeElement(int[] nums, int val) {
        int left = 0;
        int right = 0;
        for(right = 0; right < nums.length; right++){
            if(nums[right] != val) {
                nums[left++] = nums[right];
            }
        }
        return left;
    }

    public int removeDuplicates(int[] nums) {
        int left = 0;
        int right = 0;
        int[] arr = new int[nums.length + 1];
        for(right = 0; right < nums.length; right++){
            arr[nums[right]]++;
            if(arr[nums[right]] == 1){
                nums[left++] = nums[right];
            }
        }
        return left;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = new int[]{3,2,2,3};
        solution.removeElement(nums, 3);
    }
}
